#include <iostream>

using namespace std;

typedef int ElemType;

typedef struct LNode{
    ElemType data;
    struct LNode * next;
}LNode,*LinkList;

enum Status{
    OK = 10,ERROR
};

Status ListInsert(LinkList L, int i, ElemType e);
Status ListDelete(LinkList L, int i);
Status ListMerge(LinkList src1, LinkList src2,LinkList result);
void ListCreate(LinkList L, int i);

int main(void)
{
    LinkList header_node;
    header_node->next = NULL;
    ElemType value = 47;
    ListCreate(header_node,3);
    cout<<"value="<<header_node->next->next->data<<endl;
    return 0;
}

Status ListInsert(LinkList L,int i,ElemType e){

    LinkList node = L; // node用来找到插入位置
    int j = 0;
    while(node && j < i - 1){
        node = node->next;
        ++j;
    }
    if(!node || j > i-1)
        return ERROR;
    LinkList new_node = (LinkList)malloc(sizeof(LNode));
    new_node->data = e;
    new_node->next = node->next;
    node->next = new_node;
    return OK;
}
Status ListDelete(LinkList L, int i){
    /*定义一个节点用来指向需要删除的数据*/
    /*找到需要删除的节点*/
    /*修改指向*/
    LinkList node = L;
    int position = 0;
    while(node->next && position < i - 1){
        node = node->next;
        ++position;
    }
    if(!(node->next) || position > i - 1)
        return ERROR;
    node = node->next->next;
    free(node->next);
    return OK;
}
void ListCreate(LinkList L, int i){
    L->next = NULL;
    for(int num = i; num > 0; num--){
        LinkList node = (LinkList)malloc(sizeof(LNode));
        scanf("%d",&node->data);
        node->next = L->next;
        L->next = node;
    }
}

Status ListMerge(LinkList src1, LinkList src2,LinkList result){
    LinkList src1_node = src1->next;
    LinkList src2_node = src2->next;
    while(src1_node && src2_node){
        if(src1_node->data <= src2_node->data){
            result->next = src1_node;
            result = src1_node;
            src1_node = src1_node->next;
        }else{
            result->next = src2_node;
            result = src2_node;
            src2_node = src2_node->next;
        }
    }
    result->next = src1_node ? src1_node : src2_node;
}







